package cn.hl.sfzy.controller;

import cn.hl.sfzy.entity.Appointment;
import cn.hl.sfzy.service.AppointmentService;
import cn.hl.sfzy.service.ConsultService;
import cn.hl.sfzy.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName AppointmentController
 * @Description TODO
 * @Author LiuYao
 * @Date 2024年10月24日 11:00
 * @Version 1.0
 */
@RestController
@RequestMapping("/appointment")
public class AppointmentController {
    @Autowired
    private AppointmentService appointmentService;

    @DeleteMapping("/delete/{id}")
    public Object delete(@PathVariable("id") Long id){
        appointmentService.remove(id);
        return Result.success("删除成功！");
    }

    @GetMapping("/find")
    public Object find(Appointment appointment){
        List<Appointment> appointments =appointmentService.find(appointment);
        return Result.success(appointments);
    }

    @GetMapping("/findByPage")
    public Object findByPage(@RequestParam(required = false,defaultValue = "1") Integer pageNum,
                               @RequestParam(required = false,defaultValue = "5") Integer pageSize,
                               Appointment appointment){
        PageInfo pageInfo = appointmentService.findByPage(pageNum, pageSize, appointment);
        return Result.success(pageInfo);
    }
}
